# 列表 取值->1.index 索引取单个值2.slice 切片取一些值

names ="Alex,Marry,Jack"
#       01234...
# names_list=["Alex","Marry","Jack"]
# #             0       1      2
# print (names[0:4])
#print(names_list[0])


# 2.列表增加
# 2.1 append() 增加元素到list的末位
#     append() 一般用来新建列表会用到
# names = ["Mike","Marry","Jan","Jack"]
# names.append("Zhichao")
# for i in names:
#     if i[0] == "J":
#         names_J.append(i)
# print("names_J=",names_J)
# print(names)

# 2.2 insert() 插入元素
# names.insert(2,"Lihua")
# print("插入Lihua之后的names:",names)

# 3. 删除移除
# 3.1 remove() 使用remove之前应该判断该元素是否在该list当中
print("Zhichao" in names)
names_user = input("删除内容")
while True:
    if "Zhichao" in names:
        names.remove(names_user)
    else:
        break

names.remove("Zhichao")
print("remove之后的names:",names)


# 3.2 pop() 删除pop()不填内容 对应记忆==》append()删除末位
names.pop()
print(names)

# 4. index()
print(names.index("Zhichao"))

# 5.sort()排序默认从小到大排序 reverse = Fales(默认)小-大
                           reverse = True大-小
stu_成绩.sort(reverse=True)
print(stu_成绩)
names.sort() #字符串 以首字母按照ASCII编码表顺序排序
print(names)

# 6.查看某元素的次数
print(stu_成绩。count(95))

# 7.clear() 清空列表
# names.clesr()
# print(names)

# #8.extend() 是有顺序的，操作那一个列表，哪一个列表就先写
# names.extend(names_J)
# print(names)
